<template>
  <!-- 设置估价/估价修改 -->
  <el-dialog title="估价修改" :visible.sync="openGuaranteeValuationUpdate" width="1200px" append-to-body :destroy-on-close="true" :before-close="beforeClose">
    <el-form ref="form" :model="queryParams" label-width="80px" :inline="true">
      <el-form-item label="物品公司" prop="allName">
        <el-input
          v-model="queryParams.allName"
          :disabled="true"
        />
      </el-form-item>
      <el-form-item label="物品规格" prop="spzs">
        <el-input
          v-model="queryParams.spzs"
          :disabled="true"
        />
      </el-form-item>
      <el-form-item label="品牌" prop="name">
        <el-input
          v-model="queryParams.spcd"
          :disabled="true"
        />
      </el-form-item>
    </el-form>
    <el-table
        :data="valuationRevisionList"
        row-key="id"
    >
        <af-table-column prop="prrq" label="修改日期" fixed="left"></af-table-column>
        <af-table-column prop="shopname" label="修改人"></af-table-column>
        <af-table-column prop="Jine" label="货物担保单价(元/吨)"></af-table-column>
        <af-table-column prop="state" label="当前状态"></af-table-column>
        <af-table-column prop="itbz" label="备注" :show-overflow-tooltip="true"></af-table-column>
    </el-table>
    <el-form ref="form" :model="form[0]" label-width="150px">
      <el-row class="mt20">
        <el-col :span="12">
           <el-form-item label="货物担保单价(元/吨)" prop="jine">
            <el-input
              v-model="form[0].jine"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="备注" prop="itbz">
            <el-input
              v-model="form[0].itbz"
            />
          </el-form-item>
        </el-col>
      </el-row>
     
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="HandleUpdateGuaranteeValuation"  v-hasPermi="['zhcloud:hwdb:modify']">修 改</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { toValuationRevision,valuationRevision } from "@/api/storage/guarantee";

export default {
  name: "GuaranteeValuation",
  data() {
    return {
      //弹窗状态
      openGuaranteeValuationUpdate: false,
      // 查询参数
      queryParams: {
       	aid: "",
        spzs: "",
        spcd: "",
        jine: "",
        itbz: ""
      },
      //设置估价修改参数
      form: [{
        allName: "",
        itbz: "",
        jine: "",
        spbhid: "",
        spcd: "",
        spjs: "",
        spkhmcid: "",
        spsl: "",
        spzs: "",
        zje: ""
      }],
      //估价详情列表
      valuationRevisionList:[]
    };
  },
  methods: {
    /**获取估价列表 */
    getList() {
      toValuationRevision(this.queryParams).then(response => {
        this.valuationRevisionList = this.handleTree(response.data, "id")
      });
    },

    /**估价修改 */
    updateValuationRevision() {
       ;
      valuationRevision(this.form).then(response => {
        this.$modal.msg('修改成功！')
        this.getList()
        ;
      });
    },

    /**估价修改 */
    HandleUpdateGuaranteeValuation() {
        this.$modal.confirm('是否修改?').then(() => {
         this.updateValuationRevision()
        }).catch(() => {});
    },
    

    /**取消按钮 */
    cancel() {
      this.changeGuaranteeValuationUpdate()
    },

     /**改变窗口状态 */
    changeGuaranteeValuationUpdate() {
      this.openGuaranteeValuationUpdate = !this.openGuaranteeValuationUpdate;
    },

    /**关闭弹窗 */
    beforeClose(done) {
      this.changeGuaranteeValuationUpdate()
      this.$emit('refresh', true)
      done()
    },
    /**打开弹窗 */
    open(row, khmcid) {
      this.changeGuaranteeValuationUpdate()
      this.queryParams.aid = this.form[0].spkhmcid = khmcid
      this.queryParams.allName = this.form[0].allName = row.allName
      this.queryParams.spzs = this.form[0].spzs = row.spzs
      this.queryParams.spcd = this.form[0].spcd = row.spcd
      this.getList()
      
    }
  }
};
</script>
